
function getURLParam(strParamName){
    var strReturn = "";
    var strHref = window.location.href;
    if ( strHref.indexOf("?") > -1 ){
        var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
        var aQueryString = strQueryString.split("&");
        for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
            if (aQueryString[iParam].indexOf(strParamName.toLowerCase() + "=") > -1 ){
                var aParam = aQueryString[iParam].split("=");
                strReturn = aParam[1];
                break;
            }
        }
    }
    return unescape(strReturn);
} 

function loadSelectOptions(elem, option_array){
   var x=document.getElementById(elem);

   for (i=0; i< option_array.length;i++){
      var y=document.createElement('option');
      y.text=option_array[i];
      x.add(y, null);
   }
}

function clearSelectOptions(elem){
    try {
        var x=document.getElementById(elem);
        var l=x.options.length;
        for (i=0;i<l;i++){
            x.remove(0);
        }
    }
    catch (err){
        //alert(err);
    }
}

function findSelectOptionIndex(elem, elem_value){
    var x=document.getElementById(elem);
    var l=x.options.length;
    var index = 0;
    for (i=0;i<l;i++){
        if (x.options[i].text == elem_value){
            index = i;
        }
    }
    return index;
}

function setSelectedOption(elem, option_index){
    var x=document.getElementById(elem);
    x.selectedIndex=option_index;
}

function wait(msec) {
    var date = new Date();
    var curDate = null;

    do { 
        curDate = new Date();
    }
    while(curDate - date < msec);
} 

function loadAD() {
    asynchHandler.init();
    asynchHandler.setEventSink(loadAD_CallBack);
    asynchHandler.sendHttpRequest('GET','ajax-get-json-array.aspx?type=asso');
}

function loadAD_CallBack (){
    var AD = asynchHandler.receivedData;
	var ADArray = eval('(' + AD + ')' );
    clearSelectOptions('listASSO');
    loadSelectOptions('listASSO', ADArray);  
}

function loadSECTION(asso) {
    asynchHandler.init();
    asynchHandler.setEventSink(loadSECTION_CallBack);
    asynchHandler.sendHttpRequest('GET','ajax-get-json-array.aspx?type=section&asso=' + asso);
}

function loadSECTION_CallBack (){
    var AD = asynchHandler.receivedData;
	var ADArray = eval('(' + AD + ')' );
    clearSelectOptions('listSECTION');
    loadSelectOptions('listSECTION', ADArray);  
}
